{% extends "base.html" %}

{% block content %}
<style>
/* 液态玻璃效果样式 */
.page-header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
    z-index: 0;
}

.page-header > div {
    position: relative;
    z-index: 1;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1C1C1E !important;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 122, 255, 0.1);
}

.page-subtitle {
    color: #6c757d !important;
    margin-bottom: 0;
}

.btn-add {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    color: #1C1C1E !important;
}

.btn-add::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-add:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    color: #1C1C1E !important;
}

.btn-add:hover::before {
    opacity: 1;
}

.robots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.robot-card {
    background: rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 20px !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    isolation: isolate;
}

.robot-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.12) 0%, 
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.02) 100%
    );
    pointer-events: none;
    z-index: 0;
    border-radius: 20px;
}

.robot-card::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    bottom: 1px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.05) 100%
    );
    pointer-events: none;
    z-index: 0;
    border-radius: 19px;
}

.robot-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.robot-card-header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #1C1C1E;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.robot-icon {
    font-size: 2rem;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.robot-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.status-dot.active {
    background: #4ade80;
}

.status-text {
    font-size: 0.9rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.robot-card-body {
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.robot-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1C1C1E !important;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.robot-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.info-label {
    font-weight: 600;
    color: #6c757d !important;
    margin-right: 0.5rem;
    min-width: 80px;
}

.info-value {
    color: #1C1C1E !important;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.info-value:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.robot-card-footer {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.robot-actions {
    display: flex;
    gap: 0.75rem;
}

.robot-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.robot-actions .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.robot-actions .btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
}

.robot-actions .btn:hover::before {
    opacity: 1;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.empty-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
    z-index: 0;
}

.empty-state > div {
    position: relative;
    z-index: 1;
}

.empty-icon {
    font-size: 4rem;
    color: #6c757d !important;
    margin-bottom: 1.5rem;
    opacity: 0.5;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.empty-state h4 {
    color: #1C1C1E !important;
    margin-bottom: 1rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.empty-state p {
    color: #6c757d !important;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* 暗黑模式适配 */
[data-theme="dark"] .page-header {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .page-header::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
}

[data-theme="dark"] .page-title {
    color: #ffffff !important;
}

[data-theme="dark"] .page-subtitle {
    color: #bdc3c7 !important;
}

[data-theme="dark"] .btn-add {
    background: rgba(0, 0, 0, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .btn-add::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
}

[data-theme="dark"] .btn-add:hover {
    background: rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .robot-card {
    background: rgba(0, 0, 0, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .robot-card::before {
    background: linear-gradient(
        135deg, 
        rgba(255, 255, 255, 0.08) 0%, 
        rgba(255, 255, 255, 0.04) 50%,
        rgba(255, 255, 255, 0.01) 100%
    );
}

[data-theme="dark"] .robot-card::after {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
}

[data-theme="dark"] .robot-card:hover {
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 8px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .robot-card-header {
    background: rgba(0, 0, 0, 0.2);
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .robot-name {
    color: #ffffff !important;
}

[data-theme="dark"] .status-dot {
    background: #4ade80 !important;
    box-shadow: 
        0 0 10px rgba(74, 222, 128, 0.8),
        0 0 20px rgba(74, 222, 128, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .status-dot.active {
    background: #4ade80 !important;
    animation: darkPulse 2s infinite;
}

[data-theme="dark"] .status-text {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .info-label {
    color: #bdc3c7 !important;
}

[data-theme="dark"] .info-value {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .info-value:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .robot-card-footer {
    background: rgba(255, 255, 255, 0.04);
    border-top-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .robot-actions .btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .robot-actions .btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .empty-state {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .empty-state::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
}

[data-theme="dark"] .empty-icon {
    color: #bdc3c7 !important;
}

[data-theme="dark"] .empty-state h4 {
    color: #ffffff !important;
}

[data-theme="dark"] .empty-state p {
    color: #bdc3c7 !important;
}

/* 液态玻璃动画 */
@keyframes cardFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.robot-card {
    animation: cardFloat 6s ease-in-out infinite;
}

.robot-card:nth-child(2) {
    animation-delay: 1s;
}

.robot-card:nth-child(3) {
    animation-delay: 2s;
}

.robot-card:nth-child(4) {
    animation-delay: 3s;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

@keyframes darkPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 
            0 0 10px rgba(74, 222, 128, 0.8),
            0 0 20px rgba(74, 222, 128, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2);
        box-shadow: 
            0 0 15px rgba(74, 222, 128, 1),
            0 0 30px rgba(74, 222, 128, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

/* 液态玻璃响应式 */
@media (max-width: 768px) {
    .page-header {
        padding: 1.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .robots-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .robot-card-header {
        padding: 1rem;
    }
    
    .robot-card-body {
        padding: 1rem;
    }
    
    .robot-card-footer {
        padding: 1rem;
    }
    
    .robot-actions {
        flex-direction: column;
    }
}
</style>

<div class="page-header">
    <div class="d-flex justify-content-between align-items-center">
        <div>
            <h1 class="page-title">
                <i class="fas fa-robot me-2"></i>
                定时任务管理平台
            </h1>
                                                          <p class="page-subtitle">管理和配置您的消息机器人</p>
        </div>
        <a href="{{ url_for('add_robot') }}" class="btn btn-primary btn-add">
            <i class="fas fa-plus me-2"></i>
            添加机器人
        </a>
    </div>
</div>

{% if robots %}
<div class="robots-grid">
    {% for robot in robots %}
    <div class="robot-card">
        <div class="robot-card-header">
            <div class="robot-icon">
                <i class="fas fa-robot"></i>
            </div>
            <div class="robot-status">
                <span class="status-dot active"></span>
                <span class="status-text">已配置</span>
            </div>
        </div>
        
        <div class="robot-card-body">
            <h3 class="robot-name">{{ robot.name }}</h3>
            <div class="robot-info">
                <div class="info-item">
                    <i class="fas fa-tag me-2"></i>
                    <span class="info-label">机器人标签:</span>
                    <span class="info-value">{{ robot.tag }}</span>
                </div>
                <div class="info-item">
                    <i class="fas fa-user me-2"></i>
                    <span class="info-label">归属用户:</span>
                    <span class="info-value">{{ robot.user.username }}</span>
                </div>
                {% if robot.secret %}
                <div class="info-item">
                    <i class="fas fa-key me-2"></i>
                    <span class="info-label">加签密钥:</span>
                    <span class="info-value">已配置</span>
                </div>
                {% endif %}
            </div>
        </div>
        
        <div class="robot-card-footer">
            <div class="robot-actions">
                <a href="{{ url_for('edit_robot', robot_id=robot.id) }}" 
                   class="btn btn-outline-primary btn-sm" title="编辑机器人">
                    <i class="fas fa-edit"></i>
                    <span>编辑</span>
                </a>
                <a href="{{ url_for('delete_robot_page', robot_id=robot.id) }}" 
                   class="btn btn-outline-danger btn-sm" 
                   onclick="return confirm('确定要删除这个机器人吗？');" title="删除机器人">
                    <i class="fas fa-trash"></i>
                    <span>删除</span>
                </a>
            </div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<div class="empty-state">
    <div class="empty-icon">
        <i class="fas fa-robot"></i>
    </div>
    <h4>暂无机器人</h4>
                    <p>您还没有配置任何消息机器人，点击下方按钮开始添加</p>
    <a href="{{ url_for('add_robot') }}" class="btn btn-primary">
        <i class="fas fa-plus me-2"></i>
        添加第一个机器人
    </a>
</div>
{% endif %}
{% endblock %}